Skip to content

REF: _is_compatible_with_other -> _can_union_without_object_cast #36384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 18, 2020

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Changes the behavior in one test where ATM we behave differently for Series/ndarray than we do for Index arg

@jreback jreback added Index Related to the Index class or subclasses Refactor Internal refactoring of code labels Sep 17, 2020
@jorisvandenbossche
Copy link
Member

Changes the behavior in one test where ATM we behave differently for Series/ndarray than we do for Index arg

Can you show an example of that behaviour change?

@jbrockmendel
Copy link
Member Author

Can you show an example of that behaviour change?

https://github.com/pandas-dev/pandas/pull/36384/files#diff-a3619540517f93ee7c657a439b986962L50

everything = tm.makeDateIndex(10)
first = everything[:5]
second = everything[5:]

expected_old = first.astype("O").union(pd.Index(second.values, dtype="O")).astype("O")
expected_new = first.union(second)

case = list(second.values)  # <-- same for np.array(second.values)
result = first.union(case)
tm.assert_index_equal(result, expected)

ATM _is_compatible_with_other checks specifically for Index subclasses as opposed to dtype-based checks, and so we end up converting to object when we have anything that isn't an Index.

@jreback jreback added this to the 1.2 milestone Sep 17, 2020
@jreback
Copy link
Contributor

jreback commented Sep 17, 2020

can rebase

@jbrockmendel
Copy link
Member Author

Rebased +green

@jorisvandenbossche
Copy link
Member

ATM _is_compatible_with_other checks specifically for Index subclasses as opposed to dtype-based checks, and so we end up converting to object when we have anything that isn't an Index.

Thanks, then this is totally a reasonable change ;)
Can you add a whatsnew note about it? I would call it a bug fix.

@jreback jreback merged commit 56eb167 into pandas-dev:master Sep 18, 2020
@jreback
Copy link
Contributor

jreback commented Sep 18, 2020

very nice!

@jbrockmendel jbrockmendel deleted the ref-is_compatible_with branch September 18, 2020 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants